package com.fanshuai.lifecycle.aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

/**
 * 获取全局BeanFactory
 */
@Component
public class DemoBeanFactory implements BeanFactoryAware {
    private BeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
        System.out.println("bean factory=" + this.beanFactory);
    }

    public BeanFactory getBeanFactory() {
        return beanFactory;
    }
}
